#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define N 100
int n, m;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
char map[N][N];
bool vis[N][N];
bool dfs(int row, int col, int far, int fac) {
	if (vis[row][col]) {
		return true;
	}
	vis[row][col] = true;
	for (int i = 0; i < 4; ++i) {
		int nx = row + dx[i];
		int ny = col + dy[i];
		if (nx > 0 && ny > 0 && nx <= n && ny <= m && map[row][col] == map[nx][ny]) {
			if (far == nx && fac == ny)
				continue;
			if (dfs(nx, ny, row, col)) {
				return true;
			}
		}
	}
	return false;
}
int main() {
	freopen("chess.in", "r", stdin);
	freopen("chess.out", "w", stdout);
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", map[i] + 1);
	}
	for (int i = 1; i < n; ++i) {
		for (int j = 1; j <= m; ++j) {
			memset(vis, 0, sizeof(vis));
			if (dfs(i, j, -1, -1)) {
				cout << "YES";
				fclose(stdin);
				fclose(stdout);
				return 0;
			}
		}
	}
	cout << "NO";
	fclose(stdin);
	fclose(stdout);
	return 0;
}